using System;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using System.Web;

namespace Sedna.Core.Controller.Configurations
{
    public class NameValuePairListCommandArgumentsParser: IDataGridCommandArgumentsParser
    {
        public IDictionary ParseCommandArguments(string commandArguments)
        {
			IDictionary name2value = new ListDictionary();
			if (commandArguments==null||commandArguments.Trim().Equals(String.Empty))
			{
				return name2value;
			}
			string[] args =  commandArguments.Split(';');
			if(args == null || args.Length == 0)
			{
				return name2value;
			}
			foreach(string arg in args)
			{
				string[] nv = arg.Split('=');
				if(nv != null && nv.Length == 2)
				{
					name2value.Add(nv[0], HttpUtility.UrlDecode(nv[1]));
				}
			}
			return name2value;
        }
    }
}
